package com.javasm.controller;


import com.javasm.common.http.AxiosResult;
import com.javasm.common.page.PageResult;
import com.javasm.domin.criteria.SaleOutDepotCriteria;
import com.javasm.domin.entity.SodDetailConn;
import com.javasm.domin.vo.SaleOutDepotVo;
import com.javasm.domin.vo.SodSnVo;
import com.javasm.service.SaleOutDepotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whl
 * @since 2022-01-17
 */
@RestController
@RequestMapping("/sale-out-depot")
public class SaleOutDepotController {
    @Autowired
    SaleOutDepotService saleOutDepotService;

    @GetMapping("getData")
    public AxiosResult<PageResult<SaleOutDepotVo>> list(SaleOutDepotCriteria criteria){
//        System.out.println(criteria);
        PageResult<SaleOutDepotVo> pageResult = saleOutDepotService.serchPage(criteria);
        return AxiosResult.success(pageResult);
    }

    @GetMapping("/id={id}")
    public AxiosResult<SaleOutDepotVo> getById(@PathVariable Long id){
        SaleOutDepotVo byId = saleOutDepotService.getSodById(id);
        return AxiosResult.success(byId);
    }

    @GetMapping("getDetail:id={id}")
    public AxiosResult<List<SodDetailConn>> getDetail(@PathVariable Long id){
        List<SodDetailConn> detail = saleOutDepotService.getDetail(id);
//        System.out.println("=-=-=-=-=-=-=-=-==-");
//        System.out.println(detail);
        return AxiosResult.success(detail);
    }

    @GetMapping("getSn:id={id}")
    public AxiosResult<List<SodSnVo>> getSodSn(@PathVariable Long id){
        List<SodSnVo> sodSnVoList = saleOutDepotService.getSodSn(id);
        System.out.println("=-=-=-=-SN VO=-=-=-=-==-");
        System.out.println(sodSnVoList);
        return AxiosResult.success(sodSnVoList);
    }

}
